package com.gexin.controller.xapp.acitivity;

import com.gexin.common.model.ApiResponse;
import com.gexin.core.interceptor.XAppSafeInterceptor;
import com.gexin.core.web.AppController;
import com.gexin.model.activity.InviteeRelative;
import com.gexin.service.memberAcitivty.InviterService;
import com.jfinal.aop.Before;
import com.jfinal.ext.route.ControllerBind;

@Before(XAppSafeInterceptor.class)//统一错误拦截
@ControllerBind(controllerKey = "/xapp/InviterController")
public class InviterController extends AppController {

    private static final InviterService inviterService = new InviterService();


    /**
     *
     */
    public void getInviteQrCode(){
        String auth = getAuthUser().getId()+"";
        inviterService.groupByPoint();
    }



    /**
     * 推广者获得他推广过的用户
     */
    public void getRecurrent(){
        InviteeRelative recurrence = inviterService.recurrence(getAuthUser().getId()+"");
        renderJson(recurrence);
        return;
    }



    public void getInviterRelative(){
        String s = getAuthUser().getId() + "";
        InviterService inviterService = new InviterService();
        ApiResponse leaf = inviterService.getInviterListByprototype(s);
        renderJson(leaf);
        return;
    }



    /**
     * 总的邀请人数
     * @return
     */
    public ApiResponse getCountInvite(){
        String weixinUser = getAuthUser().getId()+"";
        InviterService inviterService = new InviterService();
        ApiResponse apiResponse = inviterService.getInviterListByprototype(weixinUser);
        renderJson(apiResponse);
        return apiResponse;
    }


    public void getInviteCode(){
        String id = getAuthUserId()+"";
        ApiResponse apiResponse = InviterService.getInviteCode(id);
        renderJson(apiResponse);
        return;
    }


    /**
     * 获得二维码
     */
    public void getQrcode(){
        InviterService inviterService = new InviterService();
        ApiResponse qrCode = inviterService.getQrCode();
        renderJson(qrCode);
        return;
     }


    public void unitInsert(){
        InviterService inviterService = new InviterService();
//        inviterService.unitInsert();
    }



}
